# Adds gzip compression to requests
use Rack::Deflater

# I18n Internationalization
# I18n.enforce_available_locales = false
# I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locales', '*.yml').to_s]
# I18n.default_locale = :pt

# Register Flash Sinatra messages
# register Sinatra::Flash

# Configs timezone
ActiveRecord::Base.default_timezone = :local

# Enables session
enable :sessions
set :session_secret, 'your secret key'
# use Rack::Session::Pool, :secret => 'your secret key'

# Loads database configuration
set :database, "mysql2://root:@localhost/<%= @name %>"

# configure :production do
#   db = URI.parse(ENV['DATABASE_URL'] || 'postgres:///localhost/<%= @name %>')

#   ActiveRecord::Base.establish_connection(
#     adapter:  db.scheme == 'postgres' ? 'postgresql' : db.scheme,
#     host:     db.host,
#     username: db.user,
#     password: db.password,
#     database: db.path[1..-1],
#     encoding: 'utf8'
#   )
# end

# Application helpers
# helpers do
#   # html escape method
#   def h(text)
#     Rack::Utils.escape_html(text)
#   end

#   # I18n translate method
#   def t(*args)
#     I18n.t(*args)
#   end
# end

# Loads all models in models directory
Dir["./models/*.rb"].each {|file| require file }

# Loads all controllers in controllers directory
Dir["./controllers/*.rb"].each {|file| require file }
